package zhuyun.code.launcheractivity.utils

import android.util.Log
import java.net.URLDecoder
import java.util.*

/**
 * @author: Administrator
 * @date: 2021/11/27
 */
object EncryUrl {
    fun getEncryptionParams(map:Map<String,String>):String{
        val sortMap = TreeMap<String,String>(
            Comparator<String> { p0, p1 -> p0.compareTo(p1,true)}
        )
        for(entry in map.entries){
            if(entry.value != null){
                sortMap[entry.key] = URLDecoder.decode(entry.value,"UTF-8")
            } else {
                break
            }
        }
        val resultStringBuffer = StringBuffer()
        for(entry in sortMap.entries){
            resultStringBuffer.append(entry.key).append(entry.value)
        }
        Log.d("zzz", "加密前:$resultStringBuffer")
        val signValue = EncoderData.encoderByMd5(resultStringBuffer.toString()).toLowerCase()
        Log.d("zzz","加密后:$signValue")
        return signValue
    }

}